home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr13 / jed10.zip / JEDDOC.ASC < prev    next >
Text File  |  1989-04-24  |  73KB  |  1,519 lines

  1. ╔╤╤╤╤═══════════════════════════════════════════════════╗
  2. ║││││                                                   ║
  3. ║││││  LEARNING AND USING JED                           ║
  4. ║││││                                                   ║
  5. ╟┼┼┼┼───────────────────────────────────────────────────╢
  6. ║││││  A programming environment for assembly language  ║
  7. ╚╧╧╧╧═══════════════════════════════════════════════════╝
  8.  
  9.  
  10. 1. A place to stand with access to tools
  11.  
  12. "Give me a lever long enough, and a place to stand, and I will
  13. move the Earth."
  14.      Archimedes was speaking literally about the power of the
  15. lever, but behind his words there is a larger truth about work in
  16. general: To get something done, you need a place to work, with
  17. access to tools.  My radio bench in the garage is set up that
  18. way:  A large, flat space to lay ailing transmitters down, and a
  19. shelf above where my oscilloscope, VTVM, frequency counter,
  20. signal generator, and dip meter are within easy reach.
  21.      Much of the astonishing early success of Turbo Pascal was
  22. grounded in that truth.  For the first time, a compiler vendor
  23. assembled the most important tools of software development and
  24. put them together in an intuitive fashion so that the various
  25. tasks involved in creating software flowed easily from one step
  26. to the next.  From a menu that was your place to stand, you
  27. pressed one key, and your Pascal program was compiled.  You
  28. pressed another one, and the program was run.  It was simple,
  29. fast, and easy to learn.  Turbo Pascal literally took Pascal from
  30. a backwater language favored by academics to the most popular
  31. compiled language in history, BASIC not excluded.
  32.      What Borland so boldly introduced in 1983 was adopted
  33. (reluctantly at times) by their major competitor, Microsoft. 
  34. Today, Turbo Pascal, Turbo C, Turbo Basic, Turbo Prolog, Quick C,
  35. and Quick BASIC are what we call integrated development
  36. environments.  They provide well-designed menus to give you that
  37. place to stand, and a multitude of tools that are only one or two
  38. keystrokes away.
  39.      A little remarkably, there is no true equivalent to Turbo
  40. Pascal in the assembly-language field.  Neither MASM nor
  41. Borland's own Turbo Assembler have that same comfortable place to
  42. stand.  The reasons for this may seem peculiar to you, the
  43. beginner:  Seasoned assembly-language programmers either create
  44. their own development environments (they are, after all, the
  45. programming elite) or they simply work from the naked DOS prompt. 
  46. The appeal of a Turbo Pascal-type environment is not so strong to
  47. them as it is to you.  An integrated development environment for
  48. MASM and TASM may happen in time, but you must understand that
  49. both Microsoft and Borland are catering to their most important
  50. audience, the established assembly-language programmer.
  51.      That doesn't do much good for you.  One glance at Figure 3.5
  52. on page XXX can give you the screaming willies.  Assembly
  53. language development not a simple process, and grabbing all the
  54. tools from the DOS prompt is complicated and error-prone; rather
  55. like standing on a ball-bearing bar stool to get the shot glasses
  56. down from the high shelf over the bar.
  57.      So, to make things a little easier for you, I've created a
  58. program called JED.  JED is a beginner's development environment
  59. for either MASM or TASM.  It's nowhere near as powerful as the
  60. environments provided with the Turbo or Quick languages, but it's
  61. powerful enough to get you started on the long road toward
  62. assembly language proficiency.
  63.  
  64. Laying hands on JED
  65. JED.EXE is written in Turbo Pascal 5.0.  You can get a copy from
  66. many of the larger user groups around the country.  Perhaps your
  67. friends have a copy; ask around.  I've allowed people to copy it
  68. freely in the hopes that it will be widely used.  If you can't
  69. find it anywhere, you can order the listings diskette from me
  70. through the coupon on the flyleaf.  Both source code and .EXE
  71. versions of JED are included on the listings diskette.  You don't
  72. need Turbo Pascal to run JED.EXE.  It's fully compiled and ready
  73. to run.
  74.      I must emphasize that not quite all of the source code for
  75. JED is on the listings diskette.  JED contains a powerful text
  76. editor provided with Borland's Turbo Pascal Editor Toolbox.  You
  77. can get JED's source code from the listings diskette, but keep in
  78. mind that it's not all there; you must buy the Turbo Pascal
  79. Editor Toolbox and own Turbo Pascal 5.0 in order to compile or
  80. modify JED.
  81.      
  82.  
  83. 2. JED's place to stand
  84.  
  85. Like Turbo Pascal and the other integrated development
  86. environments from both Borland and Microsoft, JED's most visible
  87. part is a text editor.  If you'll look back once again to Figure
  88. 3.5, you'll see that all roads seem to lead back to the text
  89. editor in good time.  In general, you do most of your thinking
  90. while staring at the text editor screen, so it seems a logical
  91. location to put your place to stand.
  92.      Running JED is easy.  The first time you want to work on a
  93. particular source code file, you type the name JED followed by
  94. the name of the source code file:
  95.  
  96. C:\ASM>JED EAT2.ASM
  97.  
  98. JED will be loaded from disk and run by DOS, and then JED will
  99. load the text file EAT2.ASM from disk into its editor workspace. 
  100. You'll get a view like that shown in Figure 1.
  101.  
  102.          <INSERT Figure 1. JED's edit screen JEDED.SCR>
  103.  
  104.  
  105. The status line
  106. Apart from the very top line, everything on the screen is a
  107. display of your text file.  This top line, the status line,
  108. contains several important items of information about the file
  109. JED loaded at startup, which is called the current file.  The
  110. first two items tell you the position of the cursor in terms of
  111. line number and column number.  In case you're unfamiliar with
  112. such things, the line numbers run from top to bottom with line 1
  113. at the top, and column numbers run from left to right, with
  114. column 1 at the left margin.  As you move the cursor around the
  115. file using the cursor control keys (see Section 4) the position
  116. of the cursor will be constantly updated in the status line.
  117.      The word Insert will be present in the status line if JED's
  118. editor is in insert mode, meaning that character typed at the
  119. keyboard will be inserted at the cursor position, "pushing aside"
  120. the characters to the right of the cursor position.  When the
  121. word Insert is not present, JED's editor is in overwrite mode,
  122. meaning that characters typed at the cursor position will be
  123. placed atop characters that already exist on the screen, and that
  124. those underlying characters will be lost.  I'll say more on this
  125. item later in this chapter.
  126.      Similarly, the word Indent indicates that the editor is in
  127. indent mode.  In indent mode, indenting one line by spacing over
  128. from the left margin will cause subsequent lines to automatically
  129. indent to the same number of spaces from the margin.  Again, more
  130. on this later in this chapter.
  131.      The name of the current file is present in the status line. 
  132. Finally, the current time of day as present in DOS's clock is
  133. shown in the upper right hand corner of the screen.
  134.  
  135. The prompt bar
  136. At the bottom of the screen, highlighted in blue (if you have a
  137. color screen) is a single line bar that summarizes most of JED's
  138. important commands.  This bar is called the prompt bar.  It
  139. provides always-visible reminders as to which tools are at your
  140. grasp while you are standing at JED's edit screen.  Each tool is
  141. invoked by pressing one of the PC's ten function keys.
  142.      Eight of the ten function keys are summarized in the prompt
  143. bar.  The two that are not present, F7 and F8, are actually text
  144. editing commands, and will be discussed along with all of the
  145. other editing commands in Section 4.
  146.  
  147. JED's help screen
  148. Perhaps the single most important command to remember while
  149. you're still a beginner is the Help command, F1.  Pressing F1
  150. instantly brings up a 24-line help display of all JED commands
  151. and most of the text editing commands.  If you ever forget a
  152. command or are unsure of what one of the prompt bar reminders
  153. means (like F4:Cmds, which is something less than obvious) simply
  154. press F1 and read the available information.  JED's help screen
  155. is shown in Figure 2.
  156.  
  157.         <INSERT Figure 2. JED's help screen JEDHELP.SCR>
  158.  
  159.      Once the help screen is displayed, you can put it away and
  160. return to the editing screen by pressing any non-shift key. 
  161. (That is, any key but the Shift, Ctrl, or Alt keys.)
  162.  
  163.  
  164. 3. Using JED's tools
  165.  
  166. The very best way to explain JED's commands and how they are used
  167. is to run through a simple JED session with a real assembly
  168. language program and explain what happens as we go.  The program
  169. we'll use is EAT2.ASM, which is shown in Section X.X on page XXX. 
  170. It's not much of a program, and exists only to get you started in
  171. understanding the internal mechanisms of a real, working assembly
  172. language program.  When run from the DOS prompt, EAT2.EXE
  173. displays this simple message on your screen:
  174.  
  175. Eat at Joe's...
  176. ...ten million flies can't ALL be wrong!
  177.  
  178.  
  179. After it displays those two lines, it ends and returns control to
  180. DOS.
  181.      EAT2.ASM is the source code file from which the executable
  182. program file EAT2.EXE is assembled and linked.  EAT2.ASM is
  183. present on the disk with JED.
  184.      If, as I have suggested earlier, you have created a
  185. subdirectory on your hard disk called ASM, copy all of the files
  186. on the JED disk into subdirectory ASM.  In order for JED to
  187. operate correctly, the following files must be present in the
  188. subdirectory with JED:
  189.  
  190.      1. Your assembler.  This can be any command-line
  191.      oriented assembler, but will typically be either
  192.      MASM.EXE (Microsoft's Macro Assembler) or TASM.EXE
  193.      (Borland's Turbo Assembler.)  
  194.  
  195.      2. Your assembler's linker.  Assemblers are usually
  196.      shipped with their own linker.  This is certainly true
  197.      of MASM and TASM.  Some assemblers may not use their
  198.      own linker, but will use the DOS linker LINK.EXE
  199.      instead.
  200.  
  201.      3. The DOS debugger, DEBUG.COM.  Some versions of DOS
  202.      are no longer shipped with DEBUG, which is offered as
  203.      part of an additional utilities disk.  Prior to DOS
  204.      3.2, all versions have DEBUG.COM.  
  205.  
  206.      Of course, other files can be present without any hindrance
  207. to your work.
  208.  
  209. Invoking JED
  210. Make the current directory your working assembly language
  211. subdirectory, which I have suggested you call ASM.  From the DOS
  212. prompt, invoked JED with the file name EAT2 after it:
  213.  
  214. C:\ASM>JED EAT2
  215.  
  216. Notice that you don't have to type the .ASM at the end of the
  217. file name EAT2.  JED has a default file extension of .ASM.  In
  218. other words, if you don't enter a file extension, JED will append
  219. the file extension .ASM on end of the name you enter on the
  220. command line.  You could, of course, have entered the full file
  221. name including extension if you chose:
  222.  
  223. C:\ASM>JED EAT2.ASM
  224.  
  225. JED will in either case consider the name of the current file to
  226. be EAT2.ASM.
  227.      Now, either EAT2.ASM exists on your disk or it doesn't.  JED
  228. won't mind if the file doesn't exist--new files have to start
  229. somewhere!.  If JED can't find the file whose name you enter on
  230. the command line, it will display the words "New file" in the
  231. upper left corner of the screen while it creates an empty text
  232. file on your hard disk.  When you type text into the text editor
  233. screen, JED will save the text into that new file.
  234.      The file may well exist on disk, and if it does, JED will
  235. load the file into the editor screen and display it for you. 
  236. Assuming you entered the name EAT2, the screen should look almost
  237. identical to that shown in Figure 1.
  238.      You might wonder what will happen if you simply type JED at
  239. the DOS command line without specifying any file name at all for
  240. it to work on.  One of two things will happen:
  241.  
  242.      1. JED will load the file that you last worked on from
  243.      within JED.  JED keeps a record of the last file it
  244.      loads and saves in a small file on disk named JED.CFG. 
  245.      If it can find JED.CFG, and if the file named in
  246.      JED.CFG is in your working subdirectory, JED will load
  247.      that file.  JED updates JED.CFG automatically, and you
  248.      don't need to worry about updated JED.CFG.
  249.  
  250.      2. If there is no JED.CFG on your disk, JED will create
  251.      a file imaginatively named NONAME.ASM and store your
  252.      text into a new file with that name.  NONAME.ASM is a
  253.      pretty rank name for any assembly language program, so
  254.      while it will be saved as a perfectly good file, you
  255.      might as well think of a better name and enter that
  256.      when invoking JED.
  257.  
  258.      JED's remembering the name of the last file you worked on
  259. makes it unnecessary for you to remember what project you were in
  260. the middle of when you pulled the plug and went to bed. 
  261. Furthermore, JED also remembers the cursor position where the
  262. cursor was when you saved your file and exited from JED.  Simply
  263. type JED, and JED will bring up the correct file and allow you to
  264. continue at the exact cursor position where you left off.
  265.  
  266. Moving around within the editor
  267. Your place to stand is JED's text editor, and when nothing else
  268. is going on (like assembling, linking, debugging, or running your
  269. program) you'll be in the text editor.
  270.      When you're in the text editor, any characters you type on
  271. the keyboard will be inserted into the current file and displayed
  272. on your screen.  You can move the cursor around within the
  273. current file by using any of a number of cursor movement keys.
  274.      The easiest to remember are the PC's cursor keypad keys. 
  275. The four arrow keys will move the cursor one character position
  276. in the direction the arrow points.  The PgUp key will move the
  277. cursor one page (i.e., the size of your screen; typically 25, 43,
  278. or 50 lines) up, whereas PgDn will move the cursor one page down. 
  279. The Home key will move the cursor immediately to the left screen
  280. margin, and the End key will move the cursor immediately to the
  281. end of the current line.  (The "end of the line" is defined as
  282. the character after the rightmost non-blank character in the
  283. line.)
  284.      There are numerous other cursor movement keys that you can
  285. use within JED.  I'll describe them all in detail in Section 4.
  286.      Take a few moments scooting around inside EAT2 until you
  287. feel comfortable with it.
  288.  
  289. Making changes to the file
  290. The simplest way to change the file is simply to type something
  291. at the keyboard.  All such characters will appear at the cursor,
  292. and the cursor will move one position to the right for each
  293. character.
  294.      You can insert a new line beneath the current line by
  295. pressing Enter.
  296.      Getting rid of unwanted text is as important as adding new
  297. text.  Deleting one character at a time can simply be done by
  298. moving the cursor to the immediate right of the offending
  299. character, and simply using the backspace key to back the cursor
  300. over it.  The character will disappear.
  301.      You can delete an entire line by placing the cursor on the
  302. line and pressing Ctrl-Y.  This can be done all too easily by
  303. accident, and lose a line that you may or may not have in your
  304. head or written down on paper.  Be careful!
  305.      JED contains numerous other ways to delete text, all of
  306. which will be described in Section 4.  For the sake of the
  307. current guided tour through JED, move the cursor to the blank
  308. line immediately beneath EAT2's comment header (line 9 in the
  309. file) and type the word "FOO".  That done, press Enter and add a
  310. new line beneath it.
  311.  
  312. Saving changes to a file
  313. As they say in Chicago, that grand old (and cold) town where I
  314. grew up, "Vote early and often."  The same philosophy applies to
  315. saving the changes you make to your current file under JED. 
  316. Every so often, perhaps when you kick back in your chair to think
  317. for a bit, save your work.  It's easy:  One keystroke, the
  318. function key F2.  JED will display the word "Saving..." in the
  319. status line at the top of the screen while it saves your file to
  320. disk.  If you have a fast hard disk this will rarely take more
  321. than a second.  If you're still working on diskettes, the process
  322. may take a few seconds more, especially if the current file is a
  323. good size.
  324.      Get in the habit of pressing F2 once in a while.  Keep in
  325. mind that if you save your work every five minutes, you will
  326. never lose more than five minutes of work!
  327.      JED keeps an eye on things and does its level best to keep
  328. you from losing any of your work.  If you try to exit JED without
  329. saving your file to disk, JED will remind you with the following
  330. prompt:
  331.  
  332. File modified.  Save it? (Y/N)
  333.  
  334. If you press "Y", JED will save your work to disk.  Pressing "N"
  335. will allow you to exit JED without saving your work.  All other
  336. keys but "Y" and "N" will be ignored.
  337.      JED also automatically saves your work every time you go out
  338. to use the assembler, linker, or debugger, or when you run the
  339. program you're developing, as I'll explain a little later.
  340.  
  341. Changing the current file
  342. If you want to change the current file while you're in JED and
  343. working, simply press Alt-F.  (Think: File.)  A window will
  344. appear in the center of the screen, and display the name of the
  345. current file above a field where you can enter the name of the
  346. new file.
  347.      The name of the current file will be in the field.  You can
  348. do one of two things to the name:
  349.  
  350.      ■ Begin typing a new name.  The old name will vanish as soon
  351.      as you press a printable character key.
  352.  
  353.      ■ Backspace over some portion of the old name.  This would
  354.      allow you to change the name of the current file from
  355.      EAT2.ASM to EAT3.ASM without typing the whole name.
  356.  
  357. When you press Enter, JED will attempt to load the file whose
  358. name you typed.  If the file does not exist, or if the name field
  359. was blank, JED will create a new file according to the rules
  360. summarized in the previous section.
  361.  
  362. Checking and changing the assemble and link commands
  363. The whole point of JED is to help your work in assembly language,
  364. and the central task in assembly language work is processing a
  365. correct file through an assembler.  JED can execute your
  366. assembler program and assemble your current file with only one
  367. keystroke on your part.  That keystroke is function key F9, as
  368. you'll see from the prompt bar at the bottom of the screen. 
  369. Before you press F9 on our tour, however, we'd better make sure
  370. JED has your assembler and linker commands straight.
  371.      As programs go, JED is pretty clever, but it doesn't read
  372. minds.  It can make use of any assembler that operates from the
  373. DOS command line, but you have to tell JED how to invoke the
  374. assembler you've chosen.  MASM and TASM are invoked in different
  375. ways, and JED must know which assembler you're using to be able
  376. to call the assembler program from disk and make use of it.
  377.      This is done with yet another JED command.  Press function
  378. key F4, and a whole new screen will appear, as shown in Figure 3.
  379.  
  380.  <INSERT Figure 3.  Changing JED's assembler and link commands>
  381.  
  382. JED contains two command lines, one which invokes your assembler,
  383. and another which invokes your linker.  I've set JED up to assume
  384. the use of Borland's Turbo Assembler TASM, which is faster and in
  385. many ways more sophisticated than Microsoft's MASM.  If you are
  386. using TASM, you needn't change JED's built-in default command
  387. lines.  Figure 3 shows the default command lines for TASM.
  388.      To use MASM or some other assembler, however, you'll need to
  389. change both command lines.  This will require some knowledge of
  390. how your assembler and linker operate.  I'll provide you with
  391. some basic information about MASM and TASM; for other assemblers
  392. (or for using specialized features of MASM and TASM) you're on
  393. your own.
  394.      The line beneath the prompt "Assemble command" is the line
  395. JED will use to invoke your assembler.  The default is
  396.  
  397. TASM ~
  398.  
  399. which will invoked Borland's Turbo Assembler with all default
  400. conditions in force.  The tilde character "~" is used to indicate
  401. where in the line JED is to substitute the name of the current
  402. file.  In other words, when JED goes out to DOS to execute TASM
  403. on the file EAT2.ASM, it will substitute the name "EAT2.ASM" for
  404. the tilde, and use this actual line for invoking TASM:
  405.  
  406. TASM EAT2.ASM
  407.  
  408.      If you're using MASM instead, the assemble command line must
  409. be changed.  Invoking MASM with all defaults in force (using the
  410. tilde to indicate the position of the file name) requires this
  411. command line:
  412.  
  413. MASM ~;
  414.  
  415. Again, in our example this would be expanded to 
  416.  
  417. MASM EAT2.ASM;
  418.  
  419. The semicolon is very important, and prevents MASM from going
  420. into interactive mode.  If you omit the semicolon, MASM will stop
  421. and begin asking questions from the keyboard.  JED is not
  422. equipped to answer these questions, and while you yourself could
  423. answer MASM's questions from the keyboard, there's no point to it
  424. if all we want to do is use MASM's defaults.  If you're using
  425. MASM, make sure you have that semicolon!
  426.      Modifying the command line isn't difficult.  You can
  427. backspace over the existing command line and replace it with a
  428. new one, or zap the whole line at once by pressing Ctrl-X.  Then,
  429. once the command line is empty, you can type in your new command
  430. line.
  431.      When the changes are the way you want them, press Enter to
  432. retain the changes and record them in JED.CFG.  If somehow you
  433. change your mind after zapping or otherwise altering the existing
  434. command line, you can abandon your changes and leave the original
  435. command line untouched by simply pressing Esc.
  436.      You'll notice that while you're editing a command line, a
  437. line of periods runs from the end of the command line to the
  438. right margin.  These periods indicate how large the command line
  439. can be.  You can type as far as the periods allow.  If you try to
  440. type further, JED will quite literally say "uh-uh."  Try it and
  441. see!
  442.      Changing the link command line is done the same way.  TASM's
  443. link command line is this:
  444.  
  445. TLINK ~
  446.  
  447. MASM's link command line, on the other hand, requires a
  448. semicolon, and for the same reasons mentioned before:
  449.  
  450. LINK ~;
  451.  
  452.      These are the absolute simplest command lines possible, and
  453. will suffice for simpler learning programs like EAT2.ASM.  For
  454. more advanced work you may need to use assembler or linker
  455. options, which are additional commands that provide special
  456. information to the assembler or linker about the job at hand.
  457.      For example, under MASM you can specify that the assembler
  458. write the program's segments to disk in alphabetical order (don't
  459. mind for now if you don't know what that means) by using the /A
  460. option.  This requires that you enter the /A option onto the
  461. assemble command line:
  462.  
  463. MASM /A ~;
  464.  
  465.      Both TASM and MASM have numerous options of this type.  You
  466. won't need any of them while you're just getting started.  Later
  467. on, when you graduate to larger and more sophisticated assembly
  468. language work, you will need to understand and use these options. 
  469. If you continue to use JED at that stage, you'll have to add the
  470. desired options to the assemble and link command lines.
  471.  
  472. Assembling the current file
  473. If you're satisfied that the assemble and link command lines are
  474. correct, it's time to assemble EAT2.  Press function key F9.  The
  475. following things will happen:
  476.  
  477.      1. JED will save the current file to disk, as a safety
  478.      measure.  Any time JED transfers control outside of
  479.      itself (by executing the program under development or
  480.      one of the utilities) it does this.
  481.  
  482.      2. The screen will clear.  JED will invoke your
  483.      assembler using the assemble command line described in
  484.      the previous subsection.  The assembler will display
  485.      its copyright notice and certain other information on
  486.      your screen.  (Precisely what depends on the
  487.      assembler.)  This includes error messages, if your
  488.      source code file contains errors.
  489.  
  490.      3. When the assembler is finished, JED saves the
  491.      contents of the screen onto the heap so you can bring
  492.      the information (typically error messages) back for
  493.      examination later on.  This happens invisibly and takes
  494.      almost no time.
  495.  
  496.      4. Finally, a prompt reading "Press any key to return
  497.      to JED" will appear at the center of the bottom line of
  498.      the screen.  JED will wait for any keystroke, allowing
  499.      you to take your time about reading the displayed error
  500.      messages.  When you're ready to resume work, press a
  501.      key and the editor screen will reappear.  An example of
  502.      the screen at this point is shown in Figure 4.
  503.  
  504.      If you recall, you made a change to EAT2.ASM a little
  505. earlier, by typing the word "FOO" on line 9.  This word at this
  506. location in the file means nothing, and it will generate an
  507. assembler error message.  You can see this error message as TASM
  508. presents it, along with TASM's copyright notice and other
  509. information, in Figure 4.  TASM calls the word "FOO" an "illegal
  510. instruction" because no instruction in the 86-family instruction
  511. set is named FOO.  If you misspelled a genuine instruction (say,
  512. by fumble-fingering MOV into MVO) you would most likely see the
  513. same error message.
  514.  
  515.             <INSERT Figure 4.  A TASM error message>
  516.  
  517.      Both MASM and TASM are helpful in that they identify the
  518. line where they first noticed an error.  This time, the error is
  519. a pretty obvious one and no assembler should have any trouble
  520. telling you that the problem exists in line 9 of the source code
  521. file.  Once you press a key and return to JED's edit screen, move
  522. to line 9 and delete the offending line containing "FOO."  Just
  523. press Ctrl-Y and the line will vanish.  Save the repaired file by
  524. pressing F2.  Finally, invoke the assembler again by pressing F9
  525. once more.  This time you won't see any error messages.
  526.  
  527. MAKEing an executable file, and running it
  528. What, exactly, does running the assembler actually accomplish? 
  529. By itself, not much.  Invoking the assembler alone is useful to
  530. determine if there are any errors in your source code file.  If
  531. the file contains no errors, you still don't have a runnable
  532. program after the assembler has done its job.  What you do have
  533. is a relocatable object file, with the same name as the current
  534. file but with a file extension of .OBJ.  In our example here, the
  535. assembler read in the current file EAT2.ASM and produced the new
  536. file EAT2.OBJ.
  537.      You can't run EAT2.OBJ, and you can't read it or print it. 
  538. You can't do much of anything with it, in fact, but link it.  As
  539. I explained in the previous chapter, linking is a process by
  540. which one or more .OBJ files are translated into an executable
  541. program file with an .EXE extension.  It's called "linking"
  542. because more than one .OBJ file can be combined into a single
  543. .EXE file through the linking process.  However, even if you only
  544. have one .OBJ file (as we do here with EAT2) you must still
  545. perform the link step on it to create an executable program file.
  546.      JED can perform the link step very easily.  It does not,
  547. however, perform the link step all by itself.  Running the
  548. assembler alone is useful to identify errors, but running the
  549. linker alone is pretty pointless unless you intend to run the
  550. executable program file produced by the link step.  JED combines
  551. the link step with the step of actually running your new assembly
  552. language program to see what it does.  Furthermore, it performs
  553. the assemble step again, so that you can do it all in one
  554. keystroke:  Assemble, link, and away you go!
  555.      When you press function key F10, JED will do very much what
  556. it did when you pressed F9, and then some:
  557.  
  558.      1. JED saves the current file to disk.  The first time
  559.      you run any new assembly language program, you had
  560.      better prepared to reboot your machine.  It happens to
  561.      the best of us now and then, and it will happen to you
  562.      with a disturbing frequency.  Because we humans
  563.      sometimes forget to save the source before running the
  564.      .EXE file, JED never forgets.
  565.  
  566.      2. JED executes the assembler, and if there are no
  567.      errors in the file produces an .OBJ version of the
  568.      current file.  If errors are detected, no .OBJ file is
  569.      generated and JED immediately takes control back from
  570.      the assembler.  The link and go steps are not taken. 
  571.      JED will wait for a keystroke so that you can stare at
  572.      the error messages for awhile.
  573.  
  574.      3. If there were no assembler errors, JED executes the
  575.      linker.  The .OBJ file is translated into a .EXE file. 
  576.      Again, there is the possibility that linker errors will
  577.      occur, although they are much less common than
  578.      assembler errors.  If errors are detected, JED takes
  579.      control back directly from the linker and the .EXE file
  580.      will not be run.  In the event of an error, JED waits
  581.      for a keystroke so that you can examine the wreckage
  582.      before pressing a key and going on.
  583.  
  584.      4. The .EXE file produced by the linker is executed. 
  585.      Your fledgling program runs, and when it finishes JED
  586.      will once again wait for a keystroke so that you can
  587.      examine your program's output.  In our test case of
  588.      EAT2, this output consists of those two lines of text
  589.      shown earlier about eating at Joe's.
  590.  
  591.      At this point, I have a confession to make.
  592.      What I just told you was the truth, but not the whole truth. 
  593. The F10 command is a little more complicated than just those four
  594. steps.  Suppose, for example, that you use the F10 command to
  595. create and run an .EXE file as we just did.  Then suppose that
  596. you wanted to see it work again almost immediately, without
  597. making any further changes to the program.  You press F10,
  598. expecting to have to wait through the assemble and link step
  599. again.
  600.      But no...
  601.      The second time you press F10, the .EXE file executes
  602. immediately, with neither the assembler nor the linker doing
  603. their thing.
  604.      What gives?
  605.      JED is pretty clever after all.  Since you didn't make any
  606. additional changes to the source file, there was no need for JED
  607. to re-assemble and re-link to recreate an .EXE file no different
  608. from the one created a few seconds earlier.  JED therefore simply
  609. executed the .EXE file as it did the first time, without making
  610. you wait through a needless assemble step and link step.
  611.      Here's what happens:  When you press F10, JED looks at two
  612. files on disk.  The first one is the .EXE file.  If no .EXE file
  613. exists on disk, obviously, JED has to create one by executing
  614. both the assembler and the linker.  But if the .EXE file does
  615. exist, JED looks at the file's time stamp and stores a copy of
  616. the time stamp.
  617.      A time stamp is DOS's way of knowing when a file was last
  618. changed.  Every file created under DOS has both a time and a date
  619. attached to it.  When you execute a DIR command from the DOS
  620. command line, the files listed tell you when they were last
  621. changed by displaying their time stamps as date and time values:
  622.  
  623.  Volume in drive C is DISK1_VOL1 
  624.  Directory of  C:\TURBO\JED
  625.  
  626. JED      BAK    27659   1-08-89   4:39p
  627. JED      PAS    27633   1-08-89   4:39p
  628. JED      EXE    31920   1-08-89   4:39p
  629. JED      CFG      326   1-08-89   5:25p
  630.         4 File(s)  10803200 bytes free
  631.  
  632. The two rightmost columns are the date and time portions of each
  633. file's time stamp.
  634.      Once it stores a copy of the .EXE file's time stamp, JED
  635. examines the current source code .ASM file, and stores a copy of
  636. its time stamp.  Once JED has both time stamps, it compares them.
  637.      If the .ASM file's time stamp shows a time more recent than
  638. the .EXE file's time stamp, JED re-creates the .EXE file by
  639. invoking both the assembler and the linker.  If the .ASM file's
  640. time stamp says the .ASM file is older than the .EXE file, JED
  641. simply runs the .EXE file without re-creating it.
  642.      Think about that for a moment until it makes perfect sense. 
  643. (It's important!)  If the .ASM file is older than the .EXE file,
  644. there is no possibility that changes made to the .ASM file have
  645. not been reflected in the .EXE file.  However, if the .ASM file
  646. is newer than the .EXE file, it might mean that changes were made
  647. to the .ASM file that have not yet been reflected in the .EXE
  648. file. JED therefore updates the .EXE file so that it is
  649. guaranteed to reflect all possible changes made in the source
  650. code .ASM file.
  651.      This process is a common one among software development
  652. tools.  The name of the process is "make," meaning that when
  653. necessary, JED will choose to "make" the .EXE file from the .ASM
  654. file by invoking the assembler and the linker.  The make process
  655. is efficient because it only happens when it has to.  If the .EXE
  656. file is found to be up-to-date, the assemble and link steps are
  657. skipped.
  658.      As I've hinted before, running a brand new assembly language
  659. program is dangerous business, especially for new assembly
  660. language programmers.  High-level languages like Pascal and C
  661. protect you to a considerable extent from your own ignorance. 
  662. Assembly language offers almost no such protection.  Until you
  663. really really know what you're doing, your assembly language
  664. programs will crash your machine hard more often than they let it
  665. live.  (This is why most assembly language programmers choose
  666. machines with hard-reset buttons on the front panel.  Pushing
  667. RESET is much gentler on the machine than turning it off and on
  668. again.)
  669.      So don't get discouraged when you crash.  As that old
  670. Desiderata poem on your Day-Glo '60's psychedelic posters takes
  671. pains to point out, "No doubt the universe is unfolding as it
  672. should."  Crashing is part of the process.  What is stupid is
  673. crashing again and again without knowing why.  Figuring out why
  674. you're crashing is one of the most difficult and rewarding facets
  675. of assembly language programming, as we'll see by and by.
  676.  
  677. Taking another look at your error messages
  678. The assembler won't give you a lot of clues as to where you went
  679. wrong when it detects an error, so you have to make the most of
  680. what clues you get.  The assembler displays error messages during
  681. the assemble step.  It would be handy to keep those error
  682. messages around and refer to them when you're back in JED's
  683. editor, staring at your errant source code.
  684.      JED can do it.  Before JED clears the assembler's error
  685. messages from the screen and returns you to the text editor, it
  686. saves the screen information in memory.  Later on, you can re-
  687. display the screen as it was immediately after the assemble step
  688. by pressing F6.
  689.      The only time this system fails a little bit is if you have
  690. so many errors in the source code file that they begin to scroll
  691. off the top of the screen.  This means, first of all, that you
  692. have some wholesale error hunting to do.  But there is a way to
  693. avoid losing the first few error messages of a multi-error
  694. assemble step.  As soon as the first few error messages appear,
  695. halt the assemble step by pressing Ctrl-C.  It's wise to treat
  696. the first error messages first, because error messages sometimes
  697. breed other error messages, and getting rid of the first one
  698. might well purge five or fifteen others further down the file.
  699.      If you try to recall an error message screen before running
  700. the assembler, JED will clear the screen and explain the
  701. situation.
  702.      You should also keep in mind that if an assemble step occurs
  703. without errors, you will still be able to recall the assembler's
  704. copyright notice and status information by pressing F6.  JED is
  705. not particular; whether errors occur or not, it saves the screen
  706. from the last time the assembler was run.
  707.  
  708. Running DEBUG
  709. An important part of developing assembly language programs is
  710. using the DEBUG utility.  JED can run DEBUG for you with a single
  711. keystroke.  Once you've produced a working EAT2.EXE file, press
  712. F3.  JED will invoke DEBUG.COM with your current .EXE file as its
  713. parameter.  DEBUG will execute and in turn load your .EXE file
  714. into memory.  The screen will clear, and you'll see DEBUG's terse
  715. little dash prompt.
  716.      Press D, and DEBUG will dump the first 128 bytes of EAT2.EXE
  717. as it was loaded into memory.  Press R, and debug will show you
  718. the current state of the registers.  You can actually run
  719. EAT2.EXE by pressing G (for Go) at DEBUG's prompt.  Finally, you
  720. can quit DEBUG by pressing Q.  JED will take back control and
  721. wait for one final keystroke so you can grab a last look at what
  722. DEBUG had displayed.
  723.      One additional feature is that the last screenful of
  724. information displayed by DEBUG is saved in memory by JED, and can
  725. be recalled by pressing F6, just as with assembler error screens. 
  726. This is handy when you need to refer back to a hex dump of a
  727. region of memory while examining a berserk source code file in
  728. the editor.
  729.  
  730. "Ducking out" to DOS
  731. For all that it does do, JED is a modest program and doesn't try
  732. to do everything.  I was tempted to build printer support into it
  733. so that you could create a printed listing of the current file by
  734. pressing a single key, but decided against it.  There are a
  735. multitude of different kinds of printers out there, each with its
  736. own font sizes and setup strings and control sequences.  Rather
  737. than try to cover all the printer bases, I decided to build a
  738. quick "trap door" into JED so that you can quickly "duck out" to
  739. DOS and run your own listing program, or do anything else that
  740. can be done from DOS.
  741.      This is done by pressing F5.  JED will (to be safe) save the
  742. current file out to disk, but then it will clear the screen and
  743. drop you back out to the DOS command prompt.  It looks very much
  744. like JED has terminated and returned control to DOS, but not so: 
  745. JED is very much alive in memory, waiting patiently for you to
  746. finish your business with DOS and come back home.
  747.      From DOS you can do things like search the directory for a
  748. lost file, make room on your disk be erasing some clutter, or
  749. even (in a pinch) running another major program like Turbo
  750. Pascal.  The only caution here is that JED and your program take
  751. up a certain amount of memory, memory that is therefore not
  752. available to other programs like Turbo Pascal.  Very large
  753. programs like Ventura Publisher or Paradox may not execute at all
  754. if you try to execute them from "beneath" JED, not because you've
  755. done anything wrong but only because such large programs need the
  756. memory JED is taking up.
  757.      By actual examination using the CHKDSK utility, I've found
  758. that JED and its workspace take up about 180K of RAM.  That's a
  759. lot of RAM, and you have to take its loss into account when you
  760. try to do things with JED waiting in memory.
  761.      Getting back into JED is easy.  Just type the command EXIT
  762. at the DOS command prompt.  JED will instantly take you back with
  763. open arms, and you can continue work as though you had never
  764. taken a DOS break at all.
  765.      One interesting thing to do:  Create and run a .EXE file by
  766. pressing F10, then duck out to DOS by pressing F5, and erase the
  767. .EXE file.  Once you return to JED, immediately press F10 again. 
  768. Even though you made no additional changes to the source code
  769. file, JED will search for the .EXE file before attempting to run
  770. it.  If no .EXE file can be found, JED has no choice but to re-
  771. make it.
  772.  
  773.  
  774. 4. JED's editor in detail
  775.  
  776. As JED's beating heart, the text editor deserves a little space
  777. all to itself.  JED's editor is the Borland Binary Editor,
  778. essentially the same editor as used in the Turbo languages and
  779. Sidekick.  Borland disengaged the editor module from its other
  780. products and made it available in linkable form (essentially one
  781. of those .OBJ files I described a while back) and placed it in
  782. the Turbo Pascal Editor Toolbox.  If you own the Turbo Pascal
  783. Editor Toolbox, you can read up on the Binary Editor's many
  784. commands in the Editor Toolbox documentation.  I'll describe them
  785. all briefly in this section.
  786.  
  787. Loading files into the editor
  788. When you invoke JED and it begins running, it loads either file
  789. you named on the command line, or else the last file it worked
  790. on, as recorded in JED.CFG.  The file is loaded into an area of
  791. memory called the editor workspace.  The editor workspace is
  792. limited to 64K in size, and any file to be loaded must fit into
  793. memory in its entirety.  If the file is too large to fit in
  794. available memory, you will see this message:
  795.  
  796. Insufficient text buffer size
  797.  
  798. JED will then have no choice but to throw up its hands and return
  799. to DOS.  You'll have to cut the monster file up into smaller
  800. files (which is a good idea anyway) and invoked JED again on only
  801. a portion of the oversize file.
  802.      Also keep in mind that individual lines within an edit file
  803. are limited to 248 characters.  Loading a file with longer lines
  804. will cause the editor to insert hyphens at the 248-character
  805. point.
  806.  
  807. Moving the cursor
  808. Apart from the keypad keys and function keys F7 and F8 (used for
  809. marking text blocks, as I'll explain below) all editor commands
  810. are control keystrokes.  That is, you must hold the Ctrl key down
  811. while pressing another key or two keys.  All of the keys that
  812. control cursor movement are grouped together for you in a cluster
  813. toward the left hand side of the keyboard:
  814.  
  815.           W   E   R
  816.         A   S   D   F
  817.           Z   X   C
  818.  
  819.  
  820. This arrangement of cursor command keys will be familiar to
  821. anyone who has worked with the WordStar word processor.
  822.  
  823. One character at a time
  824. Moving the cursor one character at a time can be done in all four
  825. directions:
  826.  
  827. CTRL-E or Up Arrow moves the cursor Up one character.
  828. CTRL-X or Down Arrow moves the cursor Down one character.
  829. CTRL-S or Left Arrow moves the cursor Left one character.
  830. CTRL-D or Right Arrow moves the cursor Right one character.
  831.  
  832. The position of these four keys (E, X, S, and D) provide a hint
  833. as to which way they move the cursor.  Look at how they are
  834. arranged on the keyboard:
  835.  
  836.  
  837.               E    
  838.             S   D    
  839.               X    
  840.  
  841.           
  842.      Until the directions become automatic to your fingers (as
  843. they will, if you do enough editing!) thinking of the "magic
  844. diamond" will remind you which way the cursor will move for which
  845. keypress.
  846.      When you move the cursor to the bottom of the screen and
  847. press Ctrl-X one more time, the screen will scroll.  All the
  848. lines on the screen will jump up by one, and the top line will
  849. disappear.  As long as the cursor is on the bottom line of the
  850. screen and you continue to press Ctrl-X, the screen will scroll
  851. upward.  If use Ctrl-E to move the cursor back in the opposite
  852. direction (upward) until it hits the top of the screen, further
  853. Ctrl-E's will scroll the screen downward one line per Ctrl-E.
  854.  
  855. One word at a time
  856. JED will also move the cursor one word at a time to the left or
  857. right:
  858.  
  859. CTRL-A or CTRL-Left Arrow moves the cursor Left one word.
  860. CTRL-F or CTRL-Right Arrow moves the cursor Right one word.
  861.  
  862. More hints are given here, since the A key is on the left side of
  863. the magic diamond, and the F key is on the right side of the
  864. magic diamond.
  865.  
  866. One screen at a time
  867. It is also possible to move the cursor upward or downward through
  868. the file one whole screen at a time.  "Upward" in this sense
  869. means toward the beginning of the file; "downward" means toward
  870. the end of the file.  A screen is the height of your CRT display
  871. (25, 43, or 50 lines, depending on what display adapter is
  872. installed and what font is currently loaded) minus two lines for
  873. the editor status line at the top and JED's prompt bar at the
  874. bottom.
  875.  
  876. CTRL-R or PgUp moves the cursor Up one screen.
  877. CTRL-C or PgDn moves the cursor Down one screen.
  878.  
  879. Moving the cursor by scrolling the screen
  880. I have described how the screen will scroll when you use the
  881. one-character-at-a-time commands to move upward (Ctrl-E) from the
  882. top line of the screen or downward (Ctrl-X) from the bottom line
  883. of the screen.  You can scroll the screen upward or downward no
  884. matter where the cursor happens to be by using the scrolling
  885. commands:
  886.  
  887. CTRL-W scrolls the screen Down one line.
  888. CTRL-Z scrolls the screen Up one line.
  889.  
  890. When you scroll the screen with these commands, the cursor
  891. "rides" with the screen as it scrolls upward or downward, until
  892. the cursor hits the top or bottom of the screen.  Then further
  893. scrolling will make the screen "slip past" the cursor.  The
  894. cursor will always remain visible.
  895.      These are all of the cursor movement commands which may be
  896. invoked by one Ctrl keystroke.  There are a few more that are
  897. accomplished by holding the Ctrl key down and pressing two keys
  898. in succession.  You must hold the Ctrl key down through both
  899. keypresses!
  900.  
  901. Moving to the ends of the line
  902. No matter where your cursor is on the screen, it is always within
  903. a line, even if that line happens to be empty of characters. 
  904. There are two commands that will move the cursor either to the
  905. beginning (left end) of the line (screen column 1) or to the end
  906. of the line, which is the position following the last visible
  907. character on the line:
  908.  
  909. CTRL-Q/S or Home sends the cursor to the Beginning of the line.
  910. CTRL-Q/D or End sends the cursor to the End of the line.
  911.  
  912.  
  913. Moving to the ends of the file
  914. The last set of cursor movement commands we'll describe takes the
  915. cursor to the beginning of the file or to the end of the file. 
  916. If the file you are editing is more than a few screens long, it
  917. can save you a great deal of pounding on the keyboard to move one
  918. screen at a time.
  919.  
  920. CTRL-Q/R or CTRL-PgUp sends the cursor to the Beginning of the 
  921. file.
  922. CTRL-Q/C or CTRL-PgDn sends the cursor to the End of the file.
  923.  
  924.      Because all of the current file is in memory all of the
  925. time, moving between the ends of the file can be done very
  926. quickly.
  927.  
  928.  
  929. The editor status line
  930. At the very top of JED's editor screen is the editor status line,
  931. and it provides you with some important information while you are
  932. editing.
  933.      A typical instance of the status line looks like this:
  934.  
  935. Line 1    Col 1   Insert Indent     C:EAT2.ASM             09:04:45
  936.  
  937. While you were moving the cursor around, the line and column
  938. numbers were continually changing to reflect where the cursor was
  939. in the file.  The column number reflects the position of the
  940. cursor within its line; the line number indicates which line in
  941. the file contains the cursor, counting from the beginning of the
  942. file, not from the top of the screen.  At the other end of the
  943. status line is the name of the current file.
  944.      The other words (Insert and Indent) shown as part of the
  945. status line merit some explaining.  Insert and Indent are the
  946. names of two toggles.  A toggle is a condition which may exist in
  947. one of two different states.  A toggle is like a switch
  948. controlling the lights in a room; the switch may be either on or
  949. off.
  950.      Insert determines how newly typed characters are added to
  951. your work file.  When Insert is on (that is, when the word Insert
  952. appears in the status line) characters which you type are
  953. inserted into the file.  The characters appear over the cursor
  954. and immediately push the cursor and the rest of the line to the
  955. left to make room for themselves.  The line becomes one character
  956. longer for each character which you type.  If you press Enter,
  957. the cursor moves down one line, carrying with it the part of the
  958. line lying to its right.
  959.      When Insert is off (i.e., if the word Insert is not
  960. displayed in the status line) characters which you type will
  961. overwrite characters which already exist in the file.  No new
  962. characters are added to the file unless you move the cursor to
  963. the end of the line or the end of the file and keep typing.  If
  964. you press Enter, the cursor will move down to the first character
  965. of the next line down, but nothing else will change.  A line will
  966. only be added to the file if you press Enter with the cursor on
  967. the last line of the file.
  968.      Turning Insert on and off is done with a single control
  969. keypress:
  970.  
  971. CTRL-V toggles Insert on and off.
  972.  
  973.      Indent is also a toggle.  It indicates whether JED's
  974. auto-indent feature is on or off.  When Indent is on, the cursor
  975. will automatically move beneath the first visible character on a
  976. new line when you press Enter.  In other words, (assuming that
  977. Indent is on) given this little bit of text on your screen:
  978.  
  979.  
  980. Adjust:
  981.         MOV AX, [BP] + 6
  982.         SUB AX, Increment_   <--Before pressing Enter
  983.         _
  984.  
  985.         ^ 
  986.         | After pressing Enter
  987.  
  988.  
  989. The cursor is at the end of the last line of text.  When you
  990. press Enter, the cursor will move down one line, but it will also
  991. space over automatically until it is beneath the S in SUB.  This
  992. allows you to begin typing the next line of code without having
  993. to space the cursor over so that it is beneath the start of the
  994. previous line.
  995.      Like Insert, Indent can be toggled on and off.  It takes a
  996. double control keystroke to do it:
  997.  
  998. CTRL-Q/I toggles Indent on and off.
  999.  
  1000. Indent is considered on when the word Indent appears in the
  1001. status line.
  1002.  
  1003. Tab mode
  1004. The editor status line also displays the current tab mode.  What
  1005. we call tabbing is the automatic spacing to the right upon
  1006. pressing of the Tab key.  On the PC's keyboard, there is no key
  1007. with the word "Tab" on it; instead, the key is imprinted with two
  1008. arrows pointing in opposite directions, with a vertical bar at
  1009. the head of each arrow:
  1010.  
  1011. |<--
  1012. -->|
  1013.  
  1014. Some clone keyboards do include the word "Tab;" IBM's do not.  It
  1015. is usually positioned directly over the Ctrl key.
  1016.      There are two kinds of tabs in JED's editor.  The default
  1017. tabs are not tabs as most people knew them prior to the onset of
  1018. Borland's Turbo Pascal.  These "smart" tabs move the cursor to
  1019. the position beneath the start of the next word on the previous
  1020. line.  I.e., if you had the following line on your screen with
  1021. the cursor on the line beneath it, the caret marks show where the
  1022. cursor would pause at each successive press of the Tab key:
  1023.  
  1024. Think of it as evolution in action...
  1025.       ^  ^  ^  ^         ^  ^
  1026.  
  1027. This tabbing is done by inserting spaces, not by inserting the
  1028. ASCII Tab (Ctrl-I) character.
  1029.      Smart tabs as described above are the default tab mode in
  1030. the editor.  Pressing Ctrl-O/T toggles to the opposite tab mode,
  1031. which supports true, 8-character fixed tabs that insert Ctrl-I
  1032. characters at each press of the Tab key.  If fixed tabs are in
  1033. effect, the word Tab will be shown on the status line between the
  1034. word Indent and the filename:
  1035.  
  1036. Line 1    Col 1   Insert Indent Tab C:EAT2.ASM             09:45:07
  1037.  
  1038. In summary on tab mode,
  1039.  
  1040. CTRL-O/T toggles between Smart Tabs and Fixed Tabs.
  1041.  
  1042. Inserts and deletes
  1043. We've already seen how to insert characters into a text file: 
  1044. You make sure Insert is on, and type away.  Each typed character
  1045. will be inserted into the file at the cursor position.
  1046.      It is also possible to insert entire blank lines.  One way,
  1047. of course, is to move the cursor to the beginning of a line and
  1048. press Enter.  (Insert must be on.)  A new blank line will be
  1049. inserted above the line with the cursor, and the rest of the file
  1050. will be pushed downward.  The cursor will ride down with the text
  1051. pushed downward.
  1052.      The other way to insert a line is independent of the Insert
  1053. toggle.  Move the cursor to the beginning of a line and press
  1054. Ctrl-N.  A new line will appear, pushing the rest of the file
  1055. downward, but the cursor will not move down with the other text.
  1056.  
  1057. CTRL-N inserts a New line at the cursor position.
  1058.  
  1059.      There are also a number of different ways to delete text as
  1060. well.  The simplest is to use the Del (Delete) key.  Pressing
  1061. Ctrl-G performs exactly the same delete function:
  1062.  
  1063. Del deletes one Character to the Right of the cursor.
  1064. CTRL-G deletes one Character to the Right of the cursor.
  1065.  
  1066. The cursor does not move.  It "swallows" the character to its
  1067. right, and the rest of the line to its right moves over to fill
  1068. in the position left by the deleted character.
  1069.      The Backspace key can be used to delete characters to the
  1070. left of the cursor; another way it differs from Del is that the
  1071. cursor rides to the left on each deletion:
  1072.  
  1073. Backspace deletes one Character to the Left of the cursor.
  1074.  
  1075. You can think of backspace as "eating" one character to the left
  1076. as it moves the cursor leftward.
  1077.      You can also (to save a few keystrokes) delete one word to
  1078. the right of the cursor:
  1079.  
  1080. CTRL-T deletes one Word to the Right of the cursor.
  1081.  
  1082. When you press Ctrl-T, all characters from the cursor position
  1083. rightward to the end of the current word will be deleted.  If the
  1084. cursor happens to be on a space or group of spaces between words,
  1085. that space or spaces will be deleted up to the beginning of the
  1086. next word.
  1087.      It is possible to delete from the cursor position to the end
  1088. of the cursor line:
  1089.  
  1090. CTRL-Q/Y deletes from the cursor to The end of the line.
  1091.  
  1092.      And finally, it is possible to delete the entire cursor line
  1093. with a single control keystroke:
  1094.  
  1095. CTRL-Y deletes the entire Line containing the cursor.
  1096.  
  1097. The line beneath the cursor moves up to take the place of the
  1098. deleted line, pulling up the rest of the file behind it.
  1099.      A warning here for those of you with thick fingers:  The T
  1100. and Y characters are right next to one another on the keyboard. 
  1101. In a late night frenzy at the keyboard you may find yourself
  1102. reaching for Ctrl-T to delete a word and hit Ctrl-Y instead,
  1103. losing the entire line irretrievably.  I've done this often
  1104. enough that I simply broke myself of the habit of using Ctrl-T at
  1105. all.
  1106.  
  1107. Undoing changes to a line
  1108. JED's editor keeps a "backup" copy of each line while you're
  1109. working on it, and retains that copy as long as the cursor
  1110. remains within the line.  Therefore, if you delete a word or some
  1111. other portion of the line, or add something to a line by mistake,
  1112. you can undo those changes to the line as long as you haven't yet
  1113. left the line.  Once you leave the line even momentarily, the
  1114. editor throws away the backup copy, and Undo is no longer
  1115. possible.
  1116.      
  1117. CTRL-Q/L restores a line to its condition before you entered it.
  1118.  
  1119. One drawback is that the undo feature will not restore a line
  1120. deleted entirely with the Ctrl-Y command.  Once a line is
  1121. deleted, the cursor (by necessity) leaves the line, and so the
  1122. editor does not retain the backup copy of the line.  Be careful
  1123. how you use Ctrl-Y!
  1124.  
  1125. Markers and blocks
  1126. JED's editor supports two different kinds of markers; that is,
  1127. positions in the file that have a name or number and may be moved
  1128. around as needed by the programmer.  These are place markers and
  1129. block markers.
  1130.  
  1131. Place markers
  1132. There is no such thing as a page number in an editor file.  You
  1133. can move the cursor to the beginning or end of the file with a
  1134. single command, but to move to a specific place in the file is
  1135. harder.  The best way is to remember a distinctive title,
  1136. procedure name, or something like that and search for it.  (See
  1137. below.)  You might also make use the editor's place marker
  1138. feature.
  1139.      The editor supports four place markers, numbered 0-3.  These
  1140. may be placed at any position in a text file with a single
  1141. command:
  1142.  
  1143. CTRL-K<n> sets marker <n> within a file.  <n> may be 0-3.
  1144.  
  1145. For example, to set marker 2, you would press Ctrl-K2.  
  1146.      Once a place marker has been set, you can move the cursor to
  1147. it with a single command:
  1148.  
  1149. CTRL-Q<n> moves the cursor to marker <n>.
  1150.  
  1151. For example, to move to marker 2 you would type Ctrl-Q2.  If you
  1152. have two or three "construction zones" within a largish source
  1153. file, you might drop one of the place markers at the start of
  1154. each zone, so you can shuttle between the zones with a single
  1155. command.
  1156.      The markers are invisible, and if you forget where they are
  1157. about all you can do is move the cursor to them with the Ctrl-
  1158. Q<n> command.
  1159.  
  1160. Block markers
  1161. The other kind of marker is used to specify the beginning and end
  1162. of a text block.  There are only two of these markers, and in
  1163. consequence only one block may be marked within a file at any
  1164. given time.  These are called the block markers, and their names
  1165. are B and K, after the commands that position them in your file.
  1166.      The block markers are invisible and do not appear on your
  1167. screen in any way.  If both are present in a file, however, all
  1168. the text between them (the currently marked block) is shown as
  1169. highlighted text.
  1170.      Placing each block marker is a two-character control
  1171. keystroke:
  1172.  
  1173. CTRL-K/B places the B marker.  The shortcut is F7.
  1174. CTRL-K/K places the K marker.  The shortcut is F8.
  1175.  
  1176. Note the two function key shortcuts, which are extremely
  1177. convenient and fast. 
  1178.      A marker is placed at the cursor position and remains there
  1179. until you move it elsewhere.  You cannot delete or remove a
  1180. marker once placed, although you can "hide" the block of text
  1181. which lies between the markers, which effectively gets the
  1182. markers out of the picture. (See below for more on hiding marked
  1183. blocks.)
  1184.  
  1185. Moving the cursor to a block marker
  1186. There are also commands to move the cursor to the block markers,
  1187. B and K:
  1188.  
  1189. CTRL-Q/B moves the cursor to the B marker.
  1190. CTRL-Q/K moves the cursor to the K marker.
  1191.  
  1192. Hiding and un-hiding blocks of text
  1193. The major use of markers, however, is their ability to define a
  1194. block a text.  There are a number of commands available in the
  1195. JED's editor that manipulate the text that lies between the B and
  1196. K markers.
  1197.      You probably noticed while experimenting with setting
  1198. markers that as soon as you positioned both the B and K markers
  1199. in a file, the text between them became highlighted.  The
  1200. highlighted text is a marked text block.  As we mentioned before,
  1201. there is no way to remove a marker completely from a file once it
  1202. has been set.  You can, however, suppress the highlighting of
  1203. text between the two markers.  This is called "hiding" a block:
  1204.  
  1205. CTRL-K/H will Hide a Block of text.
  1206.  
  1207. Remember that the markers are still there.  Ctrl-K/H is a
  1208. toggle.  You invoke it once to hide a block, and you can invoke
  1209. it a second time to "un-hide" the block and bring out the
  1210. highlighting again on the text between the two blocks.
  1211.      Something else to keep in mind:  The other block commands
  1212. we'll be looking it below work only on highlighted blocks.  Once
  1213. a block is hidden, it is hidden from the block commands as well
  1214. as from your eyes.
  1215.  
  1216. Marking a word as a block
  1217. The editor includes a short form of the command sequence for
  1218. marking a single word as a block.  Ordinarily, you'd have to move
  1219. the cursor to the beginning of the word, press F7, then move to
  1220. the end of the word and press F8.  With one command you can mark
  1221. a word as a block, once you've moved the cursor to any position
  1222. within that word:
  1223.  
  1224. CTRL-K/T marks the word containing the cursor as a block.
  1225.  
  1226.  
  1227. Block commands
  1228. The simplest block command to understand is delete block. 
  1229. Getting rid of big chunks of text which are no longer needed is
  1230. easy:  Mark the text as a block with the two markers, and issue
  1231. the delete block command:
  1232.  
  1233. CTRL-K/Y will Delete a Block of text.
  1234.  
  1235. The markers themselves are not destroyed with the block of text. 
  1236. They "close up" and occupy the same single cursor position, but
  1237. they are still there, and you can move the cursor to them with
  1238. the Ctrl-Q/B or Ctrl-Q/K commands.
  1239.      Copy block is useful when you have some standard text
  1240. construction (a standard boilerplate comment header for
  1241. procedures, perhaps) which you need to use several times within
  1242. the same text file.  Rather than type it in each time, you type
  1243. it once, mark it as a block, and then copy it from the original
  1244. into each position where you need it.  Simply put the cursor
  1245. where the first character of the copied text must go, and issue
  1246. copy block:
  1247.  
  1248. CTRL-K/C will Copy a Block of text to the cursor position.
  1249.  
  1250.      Moving a block of text is similar to copying a block of
  1251. text.  The difference, of course, is that the original block of
  1252. text which you marked vanishes from its original position and
  1253. reappears at the cursor position.  You must first mark the text
  1254. you wish to move as a block.  Then put the cursor where you wish
  1255. the marked text to go, and issue move block:
  1256.  
  1257. CTRL-K/V will Move a Block of text to the cursor position.
  1258.  
  1259.      The last two block commands allow you to write a block of
  1260. text to disk, or to read a text file from disk into your work
  1261. file.  Writing a block to disk begins by marking the block you
  1262. want saved as a separate text file.  Then issue the write block
  1263. command:
  1264.  
  1265. CTRL-K/W will Write a Block of text to disk.
  1266.  
  1267. The editor needs to know the name of the disk file into which you
  1268. want to write the marked block of text.  It prompts you for the
  1269. file name with a dialog box entitled "Write Block To File".  You
  1270. must type the name of the file, with full path if you intend the
  1271. block to be written outside of the current directory.  Once the
  1272. name is typed and you have pressed Enter, the block is written to
  1273. disk.  The block remains highlighted, and the cursor does not
  1274. move.
  1275.      Reading a text file from disk into your work file is also
  1276. easy.  You position the cursor to where the first character of
  1277. the text from the file should go, and issue read block:
  1278.  
  1279. CTRL-K/R will Read a Block of text from disk to the cursor
  1280. position.
  1281.  
  1282. Just as with write block, the editor will prompt you for the name
  1283. of the file which you wish to read from disk with a dialog box
  1284. entitled "Read block from file".
  1285.      There is one small "gotcha" which you must be aware of in
  1286. connection with file names.  If you enter a file name without a
  1287. period or file extension (that is, a file name like FOO rather
  1288. than FOO.ASM) JED's editor will first look for a file named FOO. 
  1289. If it does not find one, it will then look for a file named
  1290. FOO.ASM.  If it cannot find a file with the entered name plus the
  1291. .ASM file extension, it will issue this error message within an
  1292. alarming red (if you have a color screen) box:
  1293.  
  1294. Unable to open FOO.ASM.  Press <ESC>
  1295.  
  1296. Pressing Esc cancels the command entirely, and to enter the name
  1297. correctly you will need to issue the Ctrl-K/R command again.
  1298.      The text file will be read and inserted into your work file
  1299. at the cursor position.  It will come in as a marked block, and
  1300. you will have to issue the hide block command to remove the
  1301. highlighting.  Remember also that reading a block of text from
  1302. disk will effectively move your two block markers from elsewhere
  1303. in your file and place them around the text which was read in.
  1304.      The editor is not especially picky about the type of files
  1305. you read from disk.  Text files need not have been generated by
  1306. JED's editor.  Files need not be text files at all, in fact; but
  1307. remember that reading raw binary data into a text file can cause
  1308. the file to appear foreshortened: The first binary 26 (Ctrl-Z)
  1309. encountered in a text file is assumed to signal the end of the
  1310. file.  Data after that first Ctrl-Z may or may not be
  1311. accessible.  Furthermore, the editor will attempt to display the
  1312. binary characters as-is, and loading (for example) an .EXE file
  1313. will fill the screen with some pretty lively garbage.
  1314.  
  1315. Searching and replacing
  1316. Much of the power of electronic text editing lies in its ability
  1317. to search for a particular character pattern in a text file. 
  1318. Furthermore, once found, it is a logical extension of the search
  1319. concept to replace the found text string with a different text
  1320. string.  For example, if you decide to change the name of a
  1321. variable to something else to avoid conflict with another
  1322. identifier in a program, you might wish to have the text editor
  1323. locate every instance of the old variable name in a program and
  1324. replace each one with the new variable name.
  1325.      The editor can do both search and search/replace operations
  1326. with great ease.  Simply locating a given text string in a
  1327. program is often better than having page numbering (which JED's
  1328. editor does not.)  If you wish to work on the part of a program
  1329. that contains a particular procedure, all you need do is search
  1330. for that procedure's name and you will move the cursor right to
  1331. the spot you want:
  1332.  
  1333. CTRL-Q/F will Find a given text string.
  1334.  
  1335.      When you issue the Find command, the editor prompts you with
  1336. a single word:
  1337.  
  1338. Find:
  1339.  
  1340. You must then type the text string which you wish found, ending
  1341. it by pressing Enter.  The editor then prompts you for command
  1342. options:
  1343.  
  1344. Options:
  1345.  
  1346. There are several command options which may be given to both the
  1347. find and find/replace commands.  These are single letters (or
  1348. numbers), and may be grouped together in any order without spaces
  1349. in between:
  1350.  
  1351. Options: BWU
  1352.  
  1353. for example.  We'll be discussing each option in detail shortly. 
  1354. Once you press Enter after entering the options (if any) the
  1355. editor executes the command.  For the Find command, the cursor
  1356. will move to the first character of the found text string.  If
  1357. the editor cannot find any instance of the requested text string
  1358. in the work file, it displays this message:
  1359.  
  1360. Search string not found. Press <ESC>
  1361.  
  1362. You must then press Esc to continue editing.
  1363.  
  1364. Find/replace
  1365. Find/replace goes that extra step further.  Once the search text
  1366. is found, it will replace the search text with a replacement
  1367. text.  The options mean everything here; you can replace only the
  1368. first instance of the search text, or all instances, and you can
  1369. have the editor ask permission before replacing, or simply go
  1370. ahead and do the deed to as many instances of the search text as
  1371. it finds.  (This last operation is especially beloved of
  1372. programmers, who call it a "search and destroy.")
  1373.      As with Find, the editor prompts for the search text and
  1374. options.  It must also (for Find/replace) prompt for the
  1375. replacement string:
  1376.  
  1377. Replace with:
  1378.  
  1379.      If no options are in force, the editor will locate the first
  1380. instance of the search string, place the cursor beneath it, and
  1381. give you the permission prompt:
  1382.  
  1383. Replace (Y/N):
  1384.  
  1385. If you type a Y here (no Enter required) the editor will perform
  1386. the replacement.  If you type an N, nothing will change.
  1387.  
  1388. Search/replace options
  1389. The editor's find/replace options allow you to "fine-tune" a Find
  1390. or Find/replace command to cater to specific needs.  For example,
  1391. without any options the Find command is case-sensitive.  In other
  1392. words, "FOO", "foo", and "Foo" are three distinct text strings,
  1393. and searching for "FOO" will not discover instances of "foo." 
  1394. With the U option in force, however, "FOO", "foo", and "Foo" are
  1395. considered identical and searching for any of the three forms
  1396. will turn up instances of any of the three which are present. 
  1397. There are several such options to choose from within the 
  1398. editor.  In general they are the same Find/replace options used
  1399. by WordStar.
  1400.  
  1401. B is the Search Backwards option.  Ordinarily, a search will
  1402. proceed from the cursor position toward the end of the file.  If
  1403. the object of the search is closer to the beginning of the file
  1404. than the cursor, the search will not find it.  With the B option
  1405. in force, the search proceeds backwards through the file, toward
  1406. the beginning.
  1407.  
  1408. G is the Global Search option.  As mentioned above, searches
  1409. normally begin at the cursor position and proceed toward one end
  1410. of the file or the other, depending on whether or not the B
  1411. option is in force.  With the G option in force, searches begin
  1412. at the beginning of the file and proceed to the end, irrespective
  1413. of the cursor position.  The G option overrides the B option.
  1414.  
  1415. N is the Replace Without Asking option.  Without this option, the
  1416. editor (during a Find/replace) will prompt you for a yes/no
  1417. response each time it locates an instance of the search text. 
  1418. With N in force, it simply does the replacement.  Combining the G
  1419. and N options means that the editor will search the entire file
  1420. and replace every instance of the search text with the
  1421. replacement text, without asking.  Make sure you set it up right,
  1422. or you can cause wholesale damage to your work file.  In general,
  1423. don't use G and N together without W.  (See below for details on
  1424. the W option.)
  1425.  
  1426. U is the Ignore Case option.  Without this option, searches are
  1427. case-sensitive.  "FOO" and "foo" are considered distinct and
  1428. searching for one will not find the other.  With the U option in
  1429. force, corresponding lower and upper case characters are
  1430. considered identical.  "FOO" and "foo" will both be found on a
  1431. search for either.
  1432.  
  1433. W is the Whole Words option.  Without this option, the search
  1434. text will be found even when it is embedded in a larger word. 
  1435. For example, searching for "LOCK" will find both "BLOCK" and
  1436. "CLOCK".  With W in force, the search text must be bounded by
  1437. spaces to be found.  This option is especially important for
  1438. global Find/replace commands, when (if you omit W) replacing all
  1439. instances of "LOCK" with "SECURE" will change all instances of
  1440. "BLOCK" to "BSECURE" and all instances of "CLOCK" to "CSECURE".  
  1441.      You may also give a number as one of the options.  For the
  1442. Find command, this tells the editor to find the nth instance of
  1443. the search text.  For Find/replace, a number tells the editor to
  1444. find and replace text n times.
  1445.  
  1446. Find or find/replace again
  1447. The editor remembers what the last Find or Find/replace command
  1448. was, search text, replacement text, options, and all.  You can
  1449. execute that last Find or Find/replace command again simply by
  1450. issuing the Find or Find/replace again command:
  1451.  
  1452. CTRL-L will perform the last Find or Find/replace command Again.
  1453.  
  1454.      Ctrl-L can save you some considerable keystroking.  Suppose,
  1455. for example, you wanted to examine the header line of every
  1456. procedure in a large (perhaps 1000 line) program with thirty or
  1457. forty procedures.  The way to do it is to search for the string
  1458. "PROC" with the G, U, and  W options in effect.  The first
  1459. invocation of this command will find the first procedure in your
  1460. program file.  To find the next one, simply press Ctrl-L.  You
  1461. need not re-enter the search text "PROC" or the options.  Each
  1462. time you press Ctrl-L, the editor will find the next instance of
  1463. the reserved word "PROC" until it runs out of file, or until you
  1464. issue a new and different Find or Find/replace command.
  1465.  
  1466. Saving your work
  1467. It is very important to keep in mind what is happening while you
  1468. edit text files with the editor.  You are editing entirely within
  1469. memory.  Nothing goes out to disk while you are actually doing
  1470. the edit.  You can work on a file for hours, and one power
  1471. failure will throw it all away.  You must develop the discipline
  1472. of saving your work every so often.
  1473.      The easiest way to execute a Save command from within the
  1474. editor is with the Save shortcut, F2.  The "longcut" to saving
  1475. the file from within the editor is Ctrl-K/S, (useful if you have
  1476. WordStar burned into your synapses) but F2 is easier to type and
  1477. remember.
  1478.  
  1479. F2 or Ctrl-K/S always Save your work file.
  1480.  
  1481. Exiting the editor
  1482. There is more than one way to get out of JED once you're finished
  1483. with the job at hand.  You can get out with any of these
  1484. commands:
  1485.  
  1486. Ctrl-K/D saves the current file, and Exits to DOS.
  1487. Ctrl-K/Q ends the edit without saving, and Exits to DOS.
  1488. Alt-X saves the current file if necessary and Exits to DOS.
  1489.  
  1490. The differences between them are subtle.  Ctrl-K/D always saves
  1491. the current file, and exits to DOS, whether the file has been
  1492. modified or not.  If the current file is very large, this can
  1493. mean a delay of several seconds while the file is written out to
  1494. disk, especially if you're working from diskettes.
  1495.      Ctrl-KQ, on the other hand, may be used to exit from JED
  1496. without saving the current file, even if the current file has
  1497. been modified since it was last saved.  JED, always the one for
  1498. safety, will ask you if you want to abandon the changes you've
  1499. made.  You can answer only Y or N; Y will indeed exit to DOS
  1500. without saving the current file.  N, on the other hand, indicates
  1501. a change of heart on your part and JED will save the current file
  1502. to disk.
  1503.      Finally, Alt-X is the smart way out.  If you made changes to
  1504. the current file since the last time it was saved to disk, JED
  1505. will save the file to disk.  If no changes were made, JED will
  1506. not waste your time with an unnecessary save, but will drop you
  1507. out to disk immediately.
  1508.      No matter how you exit to DOS, JED considerately restores
  1509. the DOS screen that existed just before you invoked it.
  1510.      One important use of Ctrl-KQ is to "undo" a disastrous
  1511. search-and-destroy operation that went bad using Ctrl-Q/A.  If
  1512. you've changed every one of 677 instances of MOV to MUV by
  1513. accident, and haven't yet saved the damaged file to disk using
  1514. F2, your only course of action is to exit to DOS without saving
  1515. the damaged file to disk.  That done, you can re-enter JED and
  1516. the last undamaged version of the current file will be reloaded
  1517. and ready for you to try again.
  1518.      So be careful, huh?
  1519.